package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Auther: Xing Fang Bin
 * @Date: 2021/09/01/10:02
 * @Description:
 */
@RestController
public class UserController {

    IUserService userService = (IUserService) RpcClientProxy.createProxy(IUserService.class);

    @GetMapping("userInfo")
    public User userInfo(Integer userId, HttpServletRequest request) {
        System.out.println(request.getLocalPort());
        System.out.println(request.getServletPath());
        User user = userService.getById(userId);
        System.out.println(user);
        return user;
    }
}
